package com.sjk.flink.schema;

import com.fasterxml.jackson.databind.JsonNode;
import networknt.schema.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NotNullKeyword extends AbstractKeyword {
    private static final Logger logger = LoggerFactory.getLogger(GroovyKeyword.class);
    //private final ValidatorTypeCode type;
    public NotNullKeyword() {
        super("NotNull");
    }

    @Override
    public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws JsonSchemaException, Exception {
        // you can read validator config here
        String config = schemaNode.asText();
        System.out.println(">>>>>>>>>>>>>>>>>       "+config);
        //ValidatorTypeCode typeCode = ValidatorTypeCode.REQUIRED;
        // Set custom error message
        //typeCode.setCustomMessage(this.type.getCustomMessage());
        return new NotNullValidator(schemaPath,schemaNode,parentSchema,validationContext, ValidatorTypeCode.REQUIRED);
    }


}
